package com.nfIt.th02;

import java.util.Random;

/**
 * ClossName:TransactionThread
 * Pakage:com.nfIt
 * Description
 *
 * @Author L
 * @Create 2024/5/12 9:33
 * @Version 2023.1.3
 *
 */
public class TransactionThread implements Runnable{

    private Account account;

    private Integer price= new Random().nextInt(1000);

    public TransactionThread(Account account) {
        this.account = account;
    }

    @Override
    public void run() {
     min();
    }

    public synchronized void min(){


        Double deposit1 = account.deposit(Double.valueOf(price));
        System.out.println(Thread.currentThread().getName()+"存入："+price+" "+"你的余额："+deposit1);

        Integer b = new Random().nextInt(1000);
        Double withdraw = account.withdraw(b);
        System.out.println(Thread.currentThread().getName()+"取款："+b +"余额："+withdraw);
    }

}
